--[[/**
-- * 
每次格瑞娅获得能量时，佩蕾也会获得其中[2]%并储存着
 * 当储存的能量大于[0]后  释放[1]技能
-- *
-- */]]

---@class BuffEffect545100 : BaseBuffEffect
BuffEffect545100 = ClientFight.CreateClass("BuffEffect545100", ClientFight.BaseBuffEffect)
local t = BuffEffect545100
t.BUFF_EFFECT_545100_ENERGY = "BUFF_EFFECT_545100_ENERGY";
---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
    local parameters = {...};
    local fightResult = parameters[3];
    if (fightResult.damageType ~= SkillDamageTypeEnum.ENERGY) then
        return ClientFight.BaseBuffEffect.action(self, fight, buff, ...);
    end

    local effectVals = buff.buffBean.f_BuffEffectValue;
    local fighter =  parameters[1];
    local addEnergy = fightResult.damage;
    if (addEnergy <= 0) then
        return ClientFight.BaseBuffEffect.action(self, fight, buff, ...);
    end

    local save = buff.effectParams[t.BUFF_EFFECT_545100_ENERGY] or 0;
        local addSave = addEnergy * 1 * MathUtil.toRatio(effectVals[3]);
        save = save + addSave;
        if (save >= effectVals[1]) then
            ClientFight.BaseBuffEffect.triggerSkill(self,fight, fighter, nil, effectVals[2]);
        save = 0;
        end
        local logSave = save;
    SkillRoleMgr.savePathFile(string.format("[%s][EFFECT]Fighter %s  Buff%s 当前储存能量%s",
        fight.frame, buff.target.fighterIds, buff.modelId, logSave
        ));
        buff.effectParams[t.BUFF_EFFECT_545100_ENERGY] =  save;
    return ClientFight.BaseBuffEffect.action(self, fight, buff, ...);

end

t.New()